package com.zjy.basic.listener;


import com.zjy.system.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener//申明自定义的web监听器，被容器注册和使用
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private PermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        new Thread(new Runnable() {//支线程来加载这个(匿名内部类写法)
            @Override
            public void run() {
                permissionService.scanPermission();
            }
        }).start();
    }
}